/**
 * 
 */
package com.elephantgreen.xml;

import java.util.Vector;

import org.w3c.dom.Element;
import org.w3c.dom.Node;

import com.elephantgreen.common.Client;
import com.elephantgreen.common.ElephantgreenCommon;
import com.elephantgreen.util.Util;

/**
 * @author ABC
 * 
 */
public class ClientXml extends ElephantgreenXmlHandler {

	/**
	 * @param fName
	 * @param parentNodeName
	 */
	public ClientXml(String fName, String parentNodeName) {
		super(fName, parentNodeName);

	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.elephantgreen.persistance.ElephantgreenXmlHandler#getItems()
	 */
	@Override
	public Vector<ElephantgreenCommon> getItems() {

		Vector<ElephantgreenCommon> vClient = new Vector<ElephantgreenCommon>();

		for (int temp = 0; temp < getNodes().getLength(); temp++) {

			Node nNode = getNodes().item(temp);
			if (nNode.getNodeType() == Node.ELEMENT_NODE) {

				Element element = (Element) nNode;

				Client cl = new Client(
						Util.getTagValue("clientID", element),
						Util.getTagValue("clientName", element),
						Util.getTagValue("routeName", element),
						Util.getTagValue("visitingFrequency", element),
						Util.getTagValue("creditLimit", element),
						Util.getTagValue("outletType", element),
						Util.getTagValue("shopGrade", element),
						Util.getTagValue("creditPeriodDays", element),
						Util.getTagValue("streetNumber", element),
						Util.getTagValue("streetName", element),
						Util.getTagValue("city", element),
						Util.getTagValue("district", element),
						Util.getTagValue("csr", element),
								Util.getTagValue("comments", element),
								Util.getTagValue("active", element));

				vClient.add(cl);

			}
		}
		return vClient;
	}

}
